<template>
  <div class="bg">
      <div>
        <span class="text1" >双线质量管控体</span>
        <span class="text2">力求每件产品、每个细节都尽善尽美</span>
        <span class="text3">够专业 才放心</span>
      </div>
      <div class="dlBox">
        <span class="dlText1">欢迎使用</span>
        <div class="dlText2">
          <span>系统登录</span>
        </div>
        <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" >
          <el-form-item label="用户名" prop="userName" class="inputText">
            <el-input v-model="ruleForm.userName" class="inputBox"></el-input>
          </el-form-item>
          <el-form-item label="密码" prop="passWord" class="inputText">
            <el-input type="password" v-model="ruleForm.passWord" class="inputBox" ></el-input>
          </el-form-item>
        </el-form>
        <button type="button" class="dlButton" @click="submitForm">登陆</button>
      </div>
    
    <div class="bq">All Rights Reserved ©2021 版权所有 ｜ 粤ICP备18069</div>
  </div>  
  
</template>
<script>
//import HelloWorld from './components/HelloWorld.vue'
// import axios from 'axios'
import md5 from 'js-md5'
console.log(md5('111111'))

export default {
  name: 'App',
  components: {
    //HelloWorld
  },
  //自定义组件
  data(){
    return {
       ruleForm:{
         userName: '',
         passWord: ''
       },
      rules:{
        userName:[
           { required: true, message: '请输入用户名', trigger: 'blur' }
        ],
        passWord:[
           { required: true, message: '请输入密码', trigger: 'blur' }
        ]
       
      }
    }
  },
  methods:{
    submitForm(){
      this.$refs.ruleForm.validate((valid) => {
        if (valid) {
          this.$http({
            url:'/login',
            method: 'POST',
            data:{
              userName:this.ruleForm.userName,
              passWord:md5(this.ruleForm.passWord),
              platform:'Web'
            }
          }).then(res => {
            if(!res.errorMsg){
              localStorage.setItem('token',res.token)
              localStorage.setItem('user',JSON.stringify(res))
              this.$router.push('/index')           //页面跳转
            }
          })
        }
      })
    }
    
  },
  created(){

  },
  mounted(){

  }
}
</script>

<style scoped>
  .bg{
        background: url(../assets/chair.png) center center no-repeat ;
        width: 100%;
        height: 100%;
        background-size: 100%;
        
      }
      .text1{
        position: absolute;
        width: 126px;
        height: 23px;  
        font-size: 16px;
        font-family: MicrosoftYaHeiUI-Bold-, MicrosoftYaHeiUI-Bold;
        color: #FFFFFF;
        margin-top: 260px;
        margin-left: 81px;
      }
      .text2{
        position: absolute;
        width: 256px; 
        height: 20px;  
        font-size: 16px;
        font-family: MicrosoftYaHeiUI-Bold-, MicrosoftYaHeiUI-Bold;
        color: #FFFFFF;
        margin-top: 304px;
        margin-left: 0px;
      }
      .text3{
        position: absolute;
        width: 195px; 
        height: 34px; 
        font-size: 28px;
        font-family: MicrosoftYaHeiUI-Bold-, MicrosoftYaHeiUI-Bold;
        color: #6BB9DA;
        margin-left: 134px;
        margin-top: 310px;
      }
      .dlBox{
        position: absolute;
        width: 400px;
        height: 359px;
        background: #EFEFF0;
        border-radius: 20px 20px 20px 20px;
        opacity: 0.9;
        margin-top: 123px;
        margin-left: 730px;
      }
      .dlText1{
        width: 52px;
        height: 16px;
        font-size: 13px;
        font-family: MicrosoftYaHeiUI-, MicrosoftYaHeiUI;
        color: #96A3B0;
        margin-top: 23px;
        margin-left: 32px;
      }
      .dlText2{
        width: 333px;
        height: 85px;
        font-size: 27px;
        font-family: MicrosoftYaHeiUI-Bold-, MicrosoftYaHeiUI-Bold;
        font-weight: normal;
        color: #4E4E4E;
        margin-top: 6px;
        margin-left: 32px;
      }
      
      .inputText{
        font-size: 13px;
        font-family: MicrosoftYaHeiUI-, MicrosoftYaHeiUI;
        color: #737474;
        line-height: 23px;
      }
      .inputBox{
       width: 256px;
       height: 37px;
       background: #ffff;
       border-radius: 5px 5px 5px 5px;
       opacity: 1;
       border: 1px solid #DFEFFF;
      }
      .dlButton{
        width: 302px;
        height: 38px;
        background: #409EFF;
        border-radius: 19px 19px 19px 19px;
        opacity: 1;
        margin-left: 41px;
        margin-top: 33px;
      }
      .bq{
        position: absolute;
        margin-left: 446px;
        margin-top: 553px;
      }
</style>
